package com.bosssoft.hr.train.springboot.exception;

import com.bosssoft.hr.train.springboot.demo.CommonResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;

/**
 * @Author: wang
 * @Time: 2022/3/15
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    CommonResponse handleException(Exception e){
        CommonResponse r=new CommonResponse();
        if (e instanceof CommonResponse){
            r.setMessage(e.getMessage());
            r.setCode("5001");
            return r;
        }else {
            r.setCode("200");
            r.setMessage("成功");
            return r;
        }
    }
}
